/**
 * @Author Puzzle
 * @Date 2022/7/1 1:39 下午
 **/

package model

import (
	"zsc-boot/core/orm"
)

// ServiceDocument 文件储存结构体
type ServiceDocument struct {
	orm.Model
	FileName   string      `json:"fileName" form:"fileName" gorm:"column:file_name;comment:文件名称"`
	FileMd5    string      `json:"fileMd5" form:"fileMd5" gorm:"column:file_md5;comment:唯一标识"`
	Path       string      `json:"path" form:"path" gorm:"column:path;comment:文件路径"`
	Tag        string      `json:"tag" form:"tag" gorm:"column:tag;comment:标签"`
	FileSize   int64       `json:"fileSize" form:"fileSize" gorm:"column:file_size;comment:文件大小"`
	ChunkTotal uint        `json:"-" form:"-" gorm:"column:chunk_total;comment:切片数量"`
	ChunkFile  []ChunkFile `json:"-" form:"-" gorm:"foreignKey:OrderId"`
	IsDone     bool        `json:"isDone" form:"isDone" gorm:"column:is_done;comment:是否完成"`
	OwnerType  string      `json:"ownerType" form:"ownerType" gorm:"column:owner_type;comment:多态表名"`
	OwnerID    uint        `json:"ownerId" form:"ownerId" gorm:"column:owner_id;comment:多态ID"`
}

func (ServiceDocument) TableName() string {
	return "service_document"
}

func (ServiceDocument) TableComment() string {
	return "文件表"
}

// ChunkFile 切片文件结构体
type ChunkFile struct {
	ChunkMd5    string `json:"fileMd5" form:"fileMd5" gorm:"column:file_md5;comment:切片标识"`
	ChunkNumber int    `json:"chunkNumber" form:"chunkNumber" gorm:"column:chunk_number;comment:当前切片数"`
	OrderId     uint   `json:"orderId" form:"orderId" gorm:"column:order_id;comment:上级ID"`
	Path        string `json:"path" form:"path" gorm:"column:path;comment:存储地址"`
}

func (ChunkFile) TableName() string {
	return "chunk_file"
}
